/* ImageStudio ARexx script **************************************/ /* V1.0 2 Nov 97 by James Perrin */ /* V2.0 19 Nov 97 added ability to update an index if new images have been added to the directory */ /* V2.1 24 May 98 added skipping of files unable to load eg pr0gressive jpegs */ /* Allow commands to return results */ options results /* On error, goto ERROR:. Comment out this line if you wish to */ /* perform your own error checking. */ signal on error /* BEGIN PROGRAM *************************************************/ /* PROGRAM CONSTANTS - change these values to suit */ HTMLFile='Index.html' /* What to call the html file, Oh Yes */ SquareSize=100 /* Size of square into which to fit pic */ TNFormat='PNG' /* Thumbnail file format */ TNExten='png' /* Thumnail file extension */ TNPrefix='TN' /* Thumbnail prefix */ TableColumns=5 /* No. of pics per row */ TableBorder=1 /* Size of table borders, in pixels */ FilePattern='~('HTMLFile'|'TNPrefix'#?)' /* only change if you understand arexx */ /* set program variables */ nofile=0 /* flag that image can't be loaded */ /* get them files */ REQUEST_MULTIFILE TITLE '"Choose source files..."' PATTERN FilePattern STEM srcfiles. /* Open html file and write basic info */ FILE_SPLIT FILE '"'srcfiles.files.0'"' STEM getpath. FILE_JOIN PATHPART '"'getpath.pathpart'"' FILEPART HTMLFile VAR WriteFile if open('OutFile',WriteFile,'w') then do call writeln('OutFile', '') call writeln('OutFile', '') call writeln('OutFile', '') call writeln('OutFile', 'Index of Directory '||getpath.pathpart||'') call writeln('OutFile', '') call writeln('OutFile', '') call writeln('OutFile', '') ColumnCount=1 /* Process each file */ do l = 0 to (srcfiles.files.count - 1) /* Create the destination file name */ FILE_SPLIT FILE '"'srcfiles.files.l'"' STEM filesplit. filename=left(filesplit.filepart,index(filesplit.filepart,'.')-1) FILE_JOIN PATHPART '"'filesplit.pathpart'"', FILEPART '"'TNPrefix||filename'.'TNExten'"' VAR 'destfile' /* if thumb nail not yet generated make one */ if exists(destfile) ~=1 then do /* Open the file, do our own error check */ signal off error OPEN FILE '"'srcfiles.files.l'"' FORCE if (rc~=0) then do /* deal with error */ nofile=1 signal on error end else do signal on error /* Get and set size and depth info */ IMAGEINFO_GET STEM ImageInfo. XPSize = SquareSize / ImageInfo.width YPSize = SquareSize / ImageInfo.height ImageDepth = ImageInfo.depth /* 8-bit colors max */ if ImageDepth>8 then ImageDepth=8 NumCol=1 do n=1 to ImageDepth NumCol=NumCol*2 end /* Fit image into square SquareSize X SquareSize */ if (XPSize < YPSize) then PSize = (XPSize * 100) + 0.5 else PSize = (YPSize * 100) + 0.5 PSize=trunc(PSize,0) /* number must be integer */ /* Rescale image , colour convertion neccessary for colour averaging */ COLOURS SIXTEENMILLION SCALE PSize PSize PERCENT METHOD "AVERAGE" COLOURS NUMCOLOURS NumCol /* Save file */ SAVE FILE '"'destfile'"' FORMAT "PNG" ARGS '"INTERLACE=ADAM7"' end end /* if destfile */ /* Write HTML for ThumbNail */ if ColumnCount=1 then call writeln('OutFile','') if(~nofile) then /* TN exists */ call writeln('OutFile','') ColumnCount=1 end end /* file loop */ /* Finish writing html and close file */ if ColumnCount>1 then call writeln('OutFile','') call writeln('OutFile', '
'||, ''filesplit.filepart'') else /* unable to create TN */ do call writeln('OutFile',''||, filesplit.filepart'"') nofile=0 end ColumnCount=ColumnCount+1 if ColumnCount > 5 then do call writeln('OutFile','
') call writeln('OutFile', '') call writeln('OutFile', '') call close('OutFile') end /* if outfile */ /* END PROGRAM ***************************************************/ exit /* On ERROR */ ERROR: /* If we get here, either an error occurred with the command's */ /* execution or there was an error with the command itself. */ /* In the former case, rc2 contains the error message and in */ /* the latter, rc2 contains an error number. SIGL contains */ /* the line number of the command which caused the jump */ /* to ERROR: */ if datatype(rc2,'NUMERIC') == 1 then do /* See if we can describe the error with a string */ select when rc2 == 103 then err_string = "ERROR 103, "||, "out of memory at line "||SIGL when rc2 == 114 then err_string = "ERROR 114, "||, "bad command template at line "||SIGL when rc2 == 115 then err_string = "ERROR 115, "||, "bad number for /N argument at line "||SIGL when rc2 == 116 then err_string = "ERROR 116, "||, "required argument missing at line "||SIGL when rc2 == 117 then err_string = "ERROR 117, "||, "value after keywork missing at line "||SIGL when rc2 == 118 then err_string = "ERROR 118, "||, "wrong number of arguments at line "||SIGL when rc2 == 119 then err_string = "ERROR 119, "||, "unmatched quotes at line "||SIGL when rc2 == 120 then err_string = "ERROR 120, "||, "line too long at line "||SIGL when rc2 == 236 then err_string = "ERROR 236, "||, "unknown command at line "||SIGL otherwise err_string = "ERROR "||rc2||", at line "||SIGL end end else if rc2 == 'RC2' then do err_string = "ERROR in command at line "||SIGL end else do err_string = rc2||", line "||SIGL end request_message TEXT '"'err_string'"' exit